﻿using System.ComponentModel;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.Core.MFG.EnumConst;

namespace Caraya.MFG.BusinessPlugIn
{
    /// <summary>
    /// 表单服务插件
    /// </summary>
    [Description("生产入库保存测试"), HotUpdate]
    public class InStock : Kingdee.BOS.Core.Bill.PlugIn.AbstractBillPlugIn
    {
        public override void BeforeF7Select(BeforeF7SelectEventArgs e)
        {
            base.BeforeF7Select(e);
            e.DynamicFormShowParameter.MultiSelect = true;
        }
        public override void BeforeSave(Kingdee.BOS.Core.Bill.PlugIn.Args.BeforeSaveEventArgs e)
        {
            var u = this.Context;
            var fdate = this.Model.GetValue(Consts_PRD_InStock.Key_FBillDate);
            var count = this.Model.GetEntryRowCount(Consts_PRD_InStock.Key_Entry_FEntity);

            var bill = this.Model.DataObject;
            var entity = this.Model.BillBusinessInfo.GetEntryEntity(Consts_PRD_InStock.Key_Entry_FEntity);
            DynamicObjectCollection entityRows = entity.DynamicProperty.GetValue(bill) as DynamicObjectCollection;

            var FMaterial = this.View.BillBusinessInfo.GetField("FMaterialId");

            foreach (var item in entityRows)
            {
                var Seq = item["Seq"];
                var fm = FMaterial.DynamicProperty.GetValue(item) as DynamicObject;
                var fname = fm["Name"];
                var fi = item["MoEntryId"];
                System.Console.WriteLine();
            }
            for (int i = 0; i < count; i++)
            {
                var rowv = this.Model.GetValue(Consts_PRD_InStock.Key_Entry_FMoEntryId, i);
                Kingdee.BOS.Log.Logger.Error("BeforeSave", rowv.ToString(), null);
            }
            base.BeforeSave(e);
        }
        public override void BeforeSaveImportData(BeforeSaveImportDataArgs e)
        {
            base.BeforeSaveImportData(e);
        }
        public override void BeforeDoOperation(BeforeDoOperationEventArgs e)
        {
            base.BeforeDoOperation(e);
        }
    }

}
